from manimlib import *

sys.path.append("../..")
from customized import *

class p1(Scene):
    def construct(self):
        # self.add(NumberPlane())
        tri = Triangle().scale(3 / np.sqrt(3))
        a, b, c = tri.point_from_proportion(0), tri.point_from_proportion(1 / 3), tri.point_from_proportion(2 / 3)
        self.add(CustomizedCircle(radius=1.5).move_to(a), CustomizedCircle(radius=1.5).move_to(b),
                 CustomizedCircle(radius=1.5).move_to(c))
        # ab,bc,ac=CustomizedLine(a,b),CustomizedLine(b,c),CustomizedLine(a,c)
        ab = CustomizedLine(a, b, stroke_color='#ffc478').shift(LEFT * np.sqrt(3) * 0.75 + UP * 0.75)
        bc = CustomizedLine(b, c, stroke_color='#ffc478').shift(DOWN * 1.5)
        ac = CustomizedLine(a, c, stroke_color='#ffc478').shift(RIGHT * np.sqrt(3) * 0.75 + UP * 0.75)
        arc_a = CustomizedArc(30 * DEGREES, 120 * DEGREES, arc_center=a, radius=1.5, stroke_color='#ffc478')
        arc_b = CustomizedArc(150 * DEGREES, 120 * DEGREES, arc_center=b, stroke_color='#ffc478', radius=1.5)
        arc_c = CustomizedArc(270 * DEGREES, 120 * DEGREES, arc_center=c, stroke_color='#ffc478', radius=1.5)
        d = CustomizedLine(LEFT * 1.5, RIGHT * 1.5).move_to(a)
        td = CustomizedTex('d=1').next_to(d, UP)
        self.add(ab, bc, ac, arc_a, arc_b, arc_c, d, td)
        self.wait()


class p2(Scene):
    def construct(self):
        # self.add(NumberPlane())
        tri = Triangle().scale(3 / np.sqrt(3)).set_color(BLACK)
        a, b, c = tri.point_from_proportion(0), tri.point_from_proportion(1 / 3), tri.point_from_proportion(2 / 3)
        self.add(CustomizedCircle(radius=1.5).move_to(a), CustomizedCircle(radius=1.5).move_to(b),
                 CustomizedCircle(radius=1.5).move_to(c))
        # ab,bc,ac=CustomizedLine(a,b),CustomizedLine(b,c),CustomizedLine(a,c)
        ab = CustomizedLine(a, b, stroke_color='#ffc478').shift(LEFT * np.sqrt(3) * 0.75 + UP * 0.75)
        bc = CustomizedLine(b, c, stroke_color='#ffc478').shift(DOWN * 1.5)
        ac = CustomizedLine(a, c, stroke_color='#ffc478').shift(RIGHT * np.sqrt(3) * 0.75 + UP * 0.75)
        arc_a = CustomizedArc(30 * DEGREES, 120 * DEGREES, arc_center=a, radius=1.5, stroke_color='#ffc478')
        arc_b = CustomizedArc(150 * DEGREES, 120 * DEGREES, arc_center=b, stroke_color='#ffc478', radius=1.5)
        arc_c = CustomizedArc(270 * DEGREES, 120 * DEGREES, arc_center=c, stroke_color='#ffc478', radius=1.5)
        self.add(ab, bc, ac, arc_a, arc_b, arc_c, tri)
        a1, a2 = arc_a.point_from_proportion(0), arc_a.point_from_proportion(1)
        b1, b2 = arc_b.point_from_proportion(0), arc_b.point_from_proportion(1)
        c1, c2 = arc_c.point_from_proportion(0), arc_c.point_from_proportion(1)
        aa1, aa2, bb1, bb2, cc1, cc2 = CustomizedLine(a, a1), CustomizedLine(a, a2), CustomizedLine(b,
                                                                                                    b1), CustomizedLine(
            b, b2), CustomizedLine(c, c1), CustomizedLine(c, c2)
        self.add(aa1, aa2, bb1, bb2, cc1, cc2)
        q1, q2, q3 = CustomizedTex('1').next_to(tri, DOWN, buff=1.6), CustomizedTex('1').next_to(ab, UL,
                                                                                                 buff=-0.6), CustomizedTex(
            '1').next_to(ac, UR, buff=-0.6),
        self.add(q1, q2, q3)
        bc,ba=CustomizedLine(b,c),CustomizedLine(b,a)
        bb1,bb2=CustomizedLine(b,b1),CustomizedLine(b,b2)
        angle1=Angle(bc,ba)
        angle2=Angle(ba,bb1,elbow=True)
        angle3 =Angle(bb1,bb2)
        angle4 = Angle(bb2,bc,elbow=True)
        self.add(angle1, angle2, angle3, angle4,
                 CustomizedTex(r'60^\circ').next_to(angle1, UR,buff=0),
                 CustomizedTex(r'120^\circ').next_to(angle3, DL,buff=0))
        self.wait()
